package com.wbdgj.ui.booking;

import android.content.Context;
import android.widget.TextView;

import com.google.gson.internal.LinkedTreeMap;
import com.wbdgj.R;
import com.wbdgj.base.BaseApplication;
import com.wbdgj.base.BaseFragment;
import com.wbdgj.http.HttpAdapter;
import com.wbdgj.http.OnNoResponseListener;
import com.wbdgj.http.OnResponseListener;
import com.wbdgj.model.ResultObjectModel;
import com.wbdgj.utils.SpKeyUtils;

import java.text.DecimalFormat;

import butterknife.BindView;
import retrofit2.Call;

public class BookingInfo01Fragment extends BaseFragment {
    private Context context;

    @BindView(R.id.checkin_time1)
    TextView checkin_time1;
    @BindView(R.id.checkout_time1)
    TextView checkout_time1;


    @Override
    protected int getLayout() {
        return R.layout.ui_booking_info01;
    }

    @Override
    protected void onInit() {
        context = getActivity();
        hotel_info();
    }

    @Override
    public void fetchData() {

    }

    private void hotel_info() {
        Call<ResultObjectModel> call01 = HttpAdapter.getSerives().hotel_info(BaseApplication.getInstance().getSpUtil().getString(SpKeyUtils.HOTEL_ID));
        call01.enqueue(new OnResponseListener<ResultObjectModel>(context) {
            @Override
            protected void onSuccess(ResultObjectModel userModelBaseResultModel) {
                if(userModelBaseResultModel.getResultCode().equals("0000")){
                    DecimalFormat decimalFormat = new DecimalFormat("###################.###########");
                    LinkedTreeMap linkedTreeMap = (LinkedTreeMap) userModelBaseResultModel.getData();
                    LinkedTreeMap cfg_hotel = (LinkedTreeMap) linkedTreeMap.get("cfg_hotel");
                    checkout_time1.setText(cfg_hotel.get("checkout_time1")+"");
                    checkin_time1.setText(cfg_hotel.get("checkin_time1")+"");
                }
            }
        });
    }
}
